<template>
  <a-modal v-model:visible="showModal" @ok="handleOk" @cancel="handleCancel">
    <template #title> 测试表头 </template>
    <slot></slot>
  </a-modal>
</template>
<script lang='ts'>
import { defineComponent, ref, toRefs, watch } from "vue";
export default defineComponent({
  name: "BasicModal",
  props: {
    visible: Boolean,
  },
  setup(props, { emit }) {
    const { visible } = toRefs(props);
    //let propTitle = props.title;
    const showModal = ref(visible.value);
    // if (isBlankForString(propTitle)) {
    //   propTitle = getDefaultTitle(type.value);
    // }
    //const title = ref(propTitle);

    //监听visible的值 修改显示
    watch(visible, (val) => {
      showModal.value = val;
    });

    const handleOk = () => {
      emit("modalOk");
    };
    const handleCancel = () => {
      emit("update:visible", false);
      emit("modalCancel");
    };

    return {
      showModal,
      handleOk,
      handleCancel,
    };
  },
});
</script>
